package com.chixing.day04_oop;

public class MethodDemo {
    //值传递： 基本数据类型的值被 复制了一份，有两个独立的值
    public static void  fun1(int n){
        n = 20;
    }
    public static void fun3(int[] a){
        a[0] = 99;
    }

    //地址传递：引用数据类型的赋值，指向同一个堆
    public static void fun2(Car c){//Car c =car
        c.setCarName("zzz");
        c.setCarBrand("奔驰");
    }
    public static void main(String[] args) {
        int x=10 ;
        fun1(x);
        System.out.println("x="+x);

        Car car =new Car(101,"DDD车辆","特斯拉","黄色");
        fun2(car);
        System.out.println("car name:"+car.getCarName());
        System.out.println("car brand:"+car.getCarBrand());

        int[] a={10,20,30};
        fun3(a);
        System.out.println("a[0]:"+a[0]);

    }
}
